package com.nari.ncps.screen.service.impl.wholeproduct;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nari.ncps.screen.entity.wholeproduct.QtDpIndustryProfile;
import com.nari.ncps.screen.mapper.wholeproduct.QtDpIndustryProfileMapper;
import com.nari.ncps.screen.service.wholeproduct.QtDpIndustryProfileService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 产业画像表 服务实现类
 * </p>
 *
 * @author xuesong
 * @since 2025-10-12
 */
@Service
public class QtDpIndustryProfileServiceImpl extends ServiceImpl<QtDpIndustryProfileMapper, QtDpIndustryProfile> implements QtDpIndustryProfileService {

    @Override
    public List<QtDpIndustryProfile> getByIndustryType(Integer industryType) {
        QueryWrapper<QtDpIndustryProfile> queryWrapper = new QueryWrapper<>();
        if (industryType != null) {
            queryWrapper.eq("industry_type", industryType);
        }
        queryWrapper.orderByDesc("create_time");
        return this.list(queryWrapper);
    }

    @Override
    public QtDpIndustryProfile getByUnitCode(String unitCode) {
        QueryWrapper<QtDpIndustryProfile> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("unit_code", unitCode);
        queryWrapper.orderByDesc("create_time").last("LIMIT 1");
        return this.getOne(queryWrapper);
    }

}

